Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authentication to RTSP server #6

Open
mh2370 opened this issue Jan 16, 2017 · 69 comments
Open

Add authentication to RTSP server #6

mh2370 opened this issue Jan 16, 2017 · 69 comments

Comments

@mh2370
Copy link

mh2370 commented Jan 16, 2017

Can you add rstp authentication?

Thx

@mh2370 mh2370 closed this as completed Jan 16, 2017
@mh2370 mh2370 reopened this Jan 16, 2017
@tobilap
Copy link
Contributor

tobilap commented Jan 16, 2017

After writing the Image to the SD Card and setting up the scripts the RTSP server should run on
rtsp://DeviceIP:554/unicast , if it doesnt work with your synology, try checking if it works for VLC.
If you just need other RTSP options just stop the rtsp server using the scripts(or killall) and run the server (data/usr/bin/manually/snx_rtsp_server) with different options.
The server is documented here: https://github.com/haoweilo/RTSP_stream_server
If you found the right configuration for your setup just edit the 03-rtsp-server script

EDIT: @mh2370 could you please keep your original message in your Post? If you got another Question just add it to your post and do not remove the old content. Thanks

@roger-
Copy link

roger- commented Jan 17, 2017

FYI if you have a working SDK and can build stuff, then this modified RTSP server adds authentication support (but is untested): https://gist.github.com/roger-/103f4c50ed63a660f26f63171b45b010

@samtap samtap changed the title Add to synology surveilance station Add authentication to RTSP server Jan 17, 2017
@stratmetal
Copy link

This would be a great addition so we can monitor remotely with an authentication connection.

@TheZoker
Copy link

TheZoker commented Mar 3, 2017

@samtap Any news on that?

@samtap
Copy link
Owner

samtap commented Mar 3, 2017

I'm looking into this rtsp server which has builtin authentication but needs work to use with snx sdk: https://github.com/mpromonet/v4l2rtspserver

I've been very busy with other stuff recently so no progress on the xiaofang camera. I rushed the image to hopefully attract others to develop stuff but so far no volunteers ;-)

@gitingear
Copy link

I tested the code from roger (above) and authentication seems to work.
https://gist.github.com/roger-/103f4c50ed63a660f26f63171b45b010
in link above, only used lines 1-698, there is some extra code after that that should be omitted
also this is described in the code, but to clarify, the 20-rtsp-server script has to be modified to add -A option with username:password

@roger-
Copy link

roger- commented Apr 29, 2017

Awesome! I could never get the SDK to work properly so I never even got it to compile.

Could you share a binary?

@gitingear
Copy link

gitingear commented Apr 29, 2017

build env:
https://mega.nz/#!NWImyQBK!bMoytt2KtXJaGGCAjFdb-DQtM5IZS6REYSN22eXjcUI
for this build env, need to use snx/sdk/middleware/_install/lib/libsnx_rc.so on camera

@desidude2000
Copy link

what's the password to the dev account in the above ova?

@DavidRayner
Copy link

I don't know for this ova, but a different one that was shared on discord had the password devel.

@desidude2000
Copy link

desidude2000 commented May 1, 2017 via email

@DavidRayner
Copy link

DavidRayner commented May 4, 2017

There's an invite link at the bottom of the readme. Have you been able to build and test roger's code?

@a-zimmerer
Copy link

Can someone point me in the right direction how to get this started?
Is there a compiled version someone could provide me and give a
small tutorial which files to update. Thank you

@a-zimmerer
Copy link

Okay, so I managed to compile rogers modified RTSP server on the sdk enviroment. It compiled flawlessly. Problem is if I replace the RTSP server on the sd card with the modified one and restart the service. Authentication works but i only get a blank screen. Any hints ?

@desidude2000
Copy link

desidude2000 commented May 19, 2017 via email

@a-zimmerer
Copy link

a-zimmerer commented May 19, 2017

Not sure what you mean by "Which device file under /dev are you pointing the binary to" ?
Like I said I just replaced the RTSP server on the SD card with the modified one.

I am reading the stream with VLC rtsp://IP
It works perfectly with samtap's original version on SD card but not with the modified one.

I created a md5 checksum of my compiled modified snx_rtsp_server executable:
37d2b95c655f1437c37b6d87357a732f *snx_rtsp_server (1.124.900 Bytes)

@a-zimmerer
Copy link

a-zimmerer commented May 19, 2017

w00t w00t ... sooo finally my RTSP-Stream is password protected. I got this mother f*** c*** working !

You have to start the modified snx_rtsp_server with following command:
snx_rtsp_server -W 1920 -H 1080 -j 40 >$LOG 2>&1 &

@rihotopis
Copy link

rihotopis commented May 20, 2017

Hi

I understand that in order to compile the RTSP server I need to get the snx sdk from somewhere? Where could I get it?

I'd like to password protect my stream also. I'm trying to compile the server but I get this message:
In file included from main.cpp:36:0:
/home/riho/rtsp/RTSP_stream_server-master/include/sn98600_v4l2.h:5:25: fatal error: isp_lib_api.h: No such file or directory
#include "isp_lib_api.h"

Is this because I don't have the snx sdk?

@ansco11
Copy link

ansco11 commented May 22, 2017

@rihotopis
Copy link

Thanks a bunch!

@rihotopis
Copy link

Hey @a-zimmerer

Can you give any insight in how you set up the snx sdk for compiling the custom camera code?

@ansco11
Copy link

ansco11 commented May 23, 2017

For SDK 1.60 vanilla build of rtsp_server

cd /usr/src/sn986; ./sdk.unpack
cd /usr/src/sn986/snx_sdk/buildscript;
make sn98660_QR_Scan_402mhz_sf_defconfig
cd /usr/src/sn986/snx_sdk/middleware ;
mkdir -p _install/lib _install/include;
cp video/middleware/lib/lib*
rate_ctl/middleware/lib/lib*
sdrecord/middleware/lib/lib*
audio/middleware/lib/lib*
_install/lib;
cp -r video/middleware/include/snx_isp
video/middleware/include/snx_vc
rate_ctl/middleware/include/snx_rc
sdrecord/middleware/include/snx_record
audio/middleware/include/*
_install/include

PATH=/usr/src/sn986/snx_sdk/toolchain/crosstool-4.5.2/bin:${PATH}

cd /usr/src/sn986/snx_sdk/app/example/src/ipc_func/rtsp_server;
make

@rihotopis
Copy link

@ansco11

Thanks man!

@a-zimmerer
Copy link

a-zimmerer commented May 23, 2017

Problem is H.264 Stream ain't working with roger's code. Does anybody know how to get it running?
I can only get MJPEG Stream running...

@ansco11
Copy link

ansco11 commented May 23, 2017

@a-zimmerer

What version of the SDK are you using?

@newsera
Copy link

newsera commented Jul 29, 2017

@snflke @DavidRayner How to use snx_rtsp_server.zip to get authentication going? I assume the below file supports audio?
ad679a1d890981dc94427fc49d9b379c snx_rtsp_server
snx_rtsp_server.zip

@DavidRayner
Copy link

DavidRayner commented Jul 29, 2017

Audio works perfectly for me with that one yes. I think the camera must be run at 720p but you can choose the bitrate.

To use authentication extract the zip file to get the snx_rtsp_server binary (which has no file extension). Copy this onto the camera replacing the usual binary located at /media/mmcblk0p2/data/usr/bin/snx_rtsp_server. Ensure new binary has 777 permissions once on the camera.

Then modify the text file on the camera located at /media/mmcblk0p2/data/etc/scripts/20-rtsp-server so that it has a line similar to this
snx_rtsp_server -Q 10 -u media/stream1 -P 554 -A my_user:my_pass -a >$LOG 2>&1 &
instead of the usual line which executes snx_rtsp_server.

Jump on discord and ask for help if you need more detailed help.

@newsera
Copy link

newsera commented Aug 3, 2017

@DavidRayner Thank you so much.. It worked awesome..Do you know the default bitrate, width and height? Do you prefer RTSP over TCP or UDP?

@louis-lau
Copy link

@newsera Width and height is locked to 1280x720 with this server. I think the default bitrate is 1024kbps.

I prefer TCP because I'm doing motion detection on the other end, and UDP wouldn't be good for that :P

@newsera
Copy link

newsera commented Aug 3, 2017

👍 Perfect :) Works good.. I think I will buy more cameras lol.. Have been waiting for authentication for a long time now..

@ftruzzi
Copy link

ftruzzi commented Aug 12, 2017

My camera is much slower after using the snx_rtsp_server binary with authentication and sometimes reboots itself. Anyone experiencing the same issue? Sometimes it doesn't even start the RTSP stream.

@comeollas
Copy link

comeollas commented Aug 25, 2017

Hi, and thanks to all, with this post and fang hack i make work the Xiaomifang 1080 :)

When i see the rtsp is not protected in VLC i searched and see this post and modified the rtsp-server.pid

But i make an error, i put -u media/stream1 copied from here but i see "not's a good idea" because i have all default directories and now after put user and pass doen't work rtsp strem.

Anyone can help for make the correct default directori or create working media/stream1?

Thanks for all and your work.

@comeollas
Copy link

Maybe use rtsp://myuser:mypass@"deviceip":554/unicast doesn't the correct form after put pass?
In VLC if i put only rtsp://deviceip/unicast work because i need to put pass and username but after put the correct pass and user say an error.

I tryed a lot of combinations and nothing :(

@DavidRayner
Copy link

You don't need to worry about the media/* directories on the camera, the camera will handle them itself.

Inside my 20-rtsp-server file I have:

snx_rtsp_server -Q 10 -u media/stream1 -P 554 -A my_user:my_pass -a >$LOG 2>&1 &

For use with VLC I open the following stream:

rtsp://my_user:my_pass@my_ip:554/media/stream1

Are you able to access the camera from the same local network?

@comeollas
Copy link

Yes, i log in with same local network (i use one laptop conected at same wifi without firewalls or rules, and port 554 works because without modify the snxserver all work without pass) but in the moment i set the snx_rtsp_server line i can't connect to rtsp with vlc.

I go to see another time the 20-rstp.... file for see if i used caps or not in -P.

@comeollas
Copy link

Finally works, i erased -W1980 -H1080 (i don't remeber the exact but the image quality in this line i erased and works now!).

Tnx with your exact line of 20-rts... works fine.

@gabryk91
Copy link

@DavidRayner thanks for the info, it works fine, but I have a problem with TinyCam. Before the mod I could connect and see the stream even on the WAN, now I can't. Do you know how to configure tinycam or similar program on an android device? I already tried vlc for android but it get stuck. Thank you

@ardefy
Copy link

ardefy commented Sep 14, 2017

Hi, I it very good !!! thanks for this info !! :)

I also have problems with tinycam, it works well but the flow stops after a while, works in WAN and LAN with dyndns and ports redirected in NAT in my box. I think I would have to lower the quality of the rtsp stream. Is this possible with your server?

Regards :)

@gabryk91
Copy link

gabryk91 commented Sep 14, 2017 via email

@ardefy
Copy link

ardefy commented Sep 14, 2017

screenshot_20170914-165412

:)

@ardefy
Copy link

ardefy commented Sep 14, 2017

But the stream stop regularly :-(

@DavidRayner
Copy link

do you have a stable and strong upload speed from the network the camera is on?

@ardefy
Copy link

ardefy commented Sep 14, 2017

In local lan it s ok. Not in wan :(

@gabryk91
Copy link

gabryk91 commented Sep 14, 2017 via email

@halfluck
Copy link

Hey Guys,

I do not believe this is a FangHacks issue, I have this happen all the time with TinyCam and other streaming sources, It seems to only display when there is activity?

Cheers Rob.

@willthrom
Copy link

willthrom commented Sep 16, 2017

Hi,

After some digging a notice the authentication is supported by this issue hasn´t been closed.. any reason? or am I missing something? I thought the -U user:password database was for that purpose... or is it still not integrated for this Hack?

Another thing I notice is that when the v4l2rtspserver support this authentification method, live555 doesn't support encryption of the streaming. I will give try to include it using the cisco/libsrtp

By the way, do anyone know what Xiaomi client sends? Format? it might be easier to take that streaming and the controls to another server....

@samtap
Copy link
Owner

samtap commented Sep 16, 2017

I'm not sure if encrypted rtsp streams / srtp are supported well by clients. Authentication is supported in my new rtsp server (not released yet).

By the way, for simple encryption you could use stunnel, which works quite well. The downside is you also need it on the client, but maybe apps like tinycam could support it and make it less of a hassle.

@willthrom
Copy link

willthrom commented Sep 16, 2017

@samtap is v4l2rtspserver project your as well? I got confused with the fork. or you mean the compilation of v4l2rtspserver for this hack? I am trying to do the same for the Mijia 1080p. Filipowicz251/mijia-1080P-hacks#5

@samtap
Copy link
Owner

samtap commented Sep 16, 2017

No it's not my project but I'm using both https://github.com/mpromonet/v4l2rtspserver and https://github.com/haoweilo/RTSP_stream_server for my new rtsp server.

@willthrom
Copy link

willthrom commented Sep 16, 2017

Can I ask what are you missing of those project to create a new one? just curious I might be interested to participate (if possible). Actually I saw yesterday RSTP_stream_server is from v4lsrspserver....

@samtap
Copy link
Owner

samtap commented Sep 16, 2017

The drivers of XiaoFang don't allow sharing the hardware, so I want to add features like recording, snapshots, on a reasonably good code-base that already has rtsp features like auth. Tried to use pure v4l2rtspserver, abstracting all hardware access through v4l2wrapper, but gave up on that. So now I'm back to a more pragmatic approach (more hacking).
I've created a new gitter chat to discuss fang-hacks and possible also other projects if they're open to collaborate. Feel free to join: https://gitter.im/fang-hacks/ (replaces the old discord chat)

@willthrom
Copy link

@samtap Thanks, I will join and see what I can do....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests